# pip install pycryptodome ,改lib下的 crypto为Crypto解决


from Crypto.Cipher import AES

# 初始化AES对象时传入密钥，加密模式和iv
aes1 = AES.new(b'63f09k56nv2b10cf', AES.MODE_CBC, b'01pv928nv2i5ss68')
# 待加密消息,注意必须是字节码，不能是str
message_1 = "Hi!I am from the earth number 77"
message = bytes(message_1, 'utf-8')
print('待加密消息：%s' % message_1)
# 加密操作
cipher_text = aes1.encrypt(message)
print('密文：%s' % cipher_text)

# 初始化AES对象时传入与加密时相同的密钥，加密模式和iv
aes2 = AES.new(b'63f09k56nv2b10cf', AES.MODE_CBC, b'01pv928nv2i5ss68')
# 解密操作
plaint_text = aes2.decrypt(cipher_text)
print('明文：%s' % plaint_text.decode('utf8'))

# 待加密消息：Hi!I am from the earth number 77
# 密文：b'\xfbU\xd2\x1f\x9f\xdf\x0b\x1a"=5\xc5\xbd]\x80;\xee[=\x06I\x0cKZ\xd3L&(j\x98R\x11'
# 明文：Hi!I am from the earth number 77